import http from '@/utils/http'

export function Login(params: {
  phone: string
  code: string
}): Promise<{
    create_time: string
    id: number
    num: number
    phone: string
    token: string
  }> {
  return http.post(`/api/calc/login`, params).then(res => res.data)
}

export function SendSMS(params: {
  phone: string
}) {
  return http.post(`/api/calc/getSmsCode`, params).then(res => res.data)
}

export function Calc(params: {
  type: 1 | 2 | 3 | 4 | 5 | 6
  data: any
}): Promise<any> {
  return http.post(`/api/calc/doCalc`, params).then(res => res.data)
}

export function UserInfo(): Promise<{
  create_time: string
  id: number
  left_num: number
  num: number
  phone: string
  token: string
}> {
  return http.get(`/api/calc/info`).then(res => res.data)
}
